package register.Controller;

import java.io.IOException;

import javax.imageio.ImageIO;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import register.utils.PictureUtils;


@WebServlet("/imgCode")
public class ImageServlet extends HttpServlet{
    private static final long serialVersionUID = 1L;

    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
        PictureUtils bi = new PictureUtils();
        String code = bi.getCode();
        System.out.println(code);
        request.getSession().setAttribute("code",code);
        ImageIO.write(bi.getImage(), "JPG", response.getOutputStream());
    }
}
